package com.stylefeng.guns.modular.pay.controller.api;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.util.AjaxRes;
import com.stylefeng.guns.modular.pay.model.BankLimit;
import com.stylefeng.guns.modular.pay.model.Card;
import com.stylefeng.guns.modular.pay.service.IBankLimitService;
import com.stylefeng.guns.modular.pay.service.ICardService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 银行限额
 * @author Administrator
 *
 */
@Api(value="银行限额",tags="银行限额")
@Controller
@RequestMapping("/api/bankLimit")
public class ApiBankLimitController extends BaseController{
    private final static Logger logger = LoggerFactory.getLogger(ApiBankLimitController.class);
    ObjectMapper mapper = new ObjectMapper();
	@Autowired
	private IBankLimitService bankLimitService;
	@Autowired
	private ICardService cardService;
	

	@ApiOperation(value = "银行限额列表", notes = "银行限额列表")
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ResponseBody
	public AjaxRes bankLimitList() {
		List<BankLimit> bankList = bankLimitService.selectList(new EntityWrapper<BankLimit>().orderBy("id", true));
		if(bankList==null){
			return new AjaxRes("empty.data", "查询不到相关数据");
		}
		return new AjaxRes(AjaxRes.SUCCESS, "查询成功",bankList);
	}
	
	
	@ApiOperation(value = "限额信息获取", notes = "限额信息获取")
	@RequestMapping(value = "/find", method = RequestMethod.GET)
	@ResponseBody
	public AjaxRes findById(String id) {
		Card card = cardService.selectById(id);
		BankLimit bank = bankLimitService.selectById(card.getBankId());
		return new AjaxRes(AjaxRes.SUCCESS, "查询成功",bank);
	}
	
	
	
}
